package com.mangofactory.aop.configuration
{
	import com.mangofactory.aop.aspects.Aspect;

	public class PatternMatchingProxyPolicyBuilder
	{
		private var methodPattern:String;
		private var packagePattern:String;
		public function PatternMatchingProxyPolicyBuilder(packagePattern:String)
		{
			this.packagePattern = packagePattern;
		}

		public function allMethods():PatternMatchingProxyPolicyBuilder
		{
			this.methodPattern = PatternMatchingProxyPolicy.ANY_METHOD;
			return this;
		}

		public function buildWithAspect(aspect:Aspect):ProxyPolicy
		{
			return new PatternMatchingProxyPolicy(packagePattern,methodPattern,Vector.<Aspect>([aspect]));
		}
		public function buildWithAspects(aspects:Vector.<Aspect>):ProxyPolicy
		{
			return new PatternMatchingProxyPolicy(packagePattern,methodPattern,aspects);
		}

		public function forMethodsMatching(methodPattern:String):PatternMatchingProxyPolicyBuilder
		{
			this.methodPattern = methodPattern;
			return this;
		}
		public static function forPackagePattern(packagePattern:String):PatternMatchingProxyPolicyBuilder
		{
			return new PatternMatchingProxyPolicyBuilder(packagePattern);
		}
	}
}